﻿using Autofac;
using Hrm.Core;
using Hrm.EntityFramework;
using Hrm.Services;

namespace Hrm.ConsoleTest
{
    public class DependencyRegistrar : IDependencyRegistrar
    {
        public virtual void Register(ContainerBuilder builder)
        {
            builder.RegisterType<AppDomainTypeFinder>().As<ITypeFinder>().SingleInstance();
            builder.Register<IDbContext>(c => new HrmDbContext("name=connectionStrings")).InstancePerLifetimeScope();
            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
            builder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
        }

        public int Order
        {
            get { return 0; }
        }
    }
}

